From 9decb76ae3fdcc58395688e045dd1da2836c1721 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 5 Apr 2012 17:13:14 +0200 Subject: [PATCH] (bug 35649) Special:Version now shows hashes of extensions checked out from git Change-Id: I0d9540dbc103ba678dd2fb5e11c656e238e31f18 --- RELEASE-NOTES-1.20 | 1 + includes/specials/SpecialVersion.php | 35 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 75e3cfbc28..7dd6b882fd 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -32,6 +32,7 @@ production. * (bug 22870) Separate interface message when creating a page. * (bug 17615) nosummary option should be reassigned on preview/captcha. * (bug 34355) add a variable and parser function for the namespace number. +* (bug 35649) Special:Version now shows hashes of extensions checked out from git. === Bug fixes in 1.20 === * (bug 30245) Use the correct way to construct a log page title. diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 9181de0b75..76d60c787f 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -415,15 +415,22 @@ class SpecialVersion extends SpecialPage { function getCreditsForExtension( array $extension ) { $name = isset( $extension['name'] ) ? $extension['name'] : '[no name]'; + $vcsText = false; + if ( isset( $extension['path'] ) ) { - $svnInfo = self::getSvnInfo( dirname($extension['path']) ); - $directoryRev = isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : null; - $checkoutRev = isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : null; - $viewvcUrl = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : null; - } else { - $directoryRev = null; - $checkoutRev = null; - $viewvcUrl = null; + $gitInfo = new GitInfo( dirname( $extension['path'] ) ); + $gitHeadSHA1 = $gitInfo->getHeadSHA1(); + if ( $gitHeadSHA1 !== false ) { + $vcsText = substr( $gitHeadSHA1, 0, 7 ); + } else { + $svnInfo = self::getSvnInfo( dirname( $extension['path'] ) ); + # Make subversion text/link. + if ( $svnInfo !== false ) { + $directoryRev = isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : null; + $vcsText = wfMsg( 'version-svn-revision', $directoryRev, $svnInfo['checkout-rev'] ); + $vcsText = isset( $svnInfo['viewvc-url'] ) ? '[' . $svnInfo['viewvc-url'] . " $vcsText]" : $vcsText; + } + } } # Make main link (or just the name if there is no URL). @@ -441,14 +448,6 @@ class SpecialVersion extends SpecialPage { $versionText = ''; } - # Make subversion text/link. - if ( $checkoutRev ) { - $svnText = wfMsg( 'version-svn-revision', $directoryRev, $checkoutRev ); - $svnText = isset( $viewvcUrl ) ? "[$viewvcUrl $svnText]" : $svnText; - } else { - $svnText = false; - } - # Make description text. $description = isset ( $extension['description'] ) ? $extension['description'] : ''; @@ -466,10 +465,10 @@ class SpecialVersion extends SpecialPage { } } - if ( $svnText !== false ) { + if ( $vcsText !== false ) { $extNameVer = " $mainLink $versionText - $svnText"; + $vcsText"; } else { $extNameVer = " $mainLink $versionText"; -- 2.20.1